package com.net;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * AT模式
 *
 * @author 猿仁
 * @date 2023/3/4 20:14
 */
@Slf4j
@SpringBootApplication(scanBasePackages = "com.net", exclude = DataSourceAutoConfiguration.class)
@MapperScan(basePackages = "com.net.**.mapper")
public class InventoryApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(InventoryApplication.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();
        StringBuilder commandLog = new StringBuilder();
        commandLog.append("\n+=================================================================================");
        commandLog.append("\n+        项目[{}]启动成功！！！");
        commandLog.append("\n+        当前环境: {}");
        commandLog.append("\n+        IP:PORT: {}:{}");
        commandLog.append("\n+        SEATA模式: AT");
        commandLog.append("\n+=================================================================================");
        log.info(commandLog.toString(),
                environment.getProperty("spring.application.name"),
                environment.getProperty("spring.profiles.active"),
                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"));
    }

}
